/*******************************************************************************************
This file is part of iToday.

iToday is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

iToday is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with iToday.  If not, see <http://www.gnu.org/licenses/>.
* ------------------------------------------------------------------------------
*    TimeUtility.h - Utility for time
* ------------------------------------------------------------------------------
*    Revision History
*    Date                  Author         Activity ID               Activity Headline
*    2009-10-13            Congqin				none						initial
*******************************************************************************************/

#pragma once

#define TOCHAR(X)  (char)( (int)'0' + X )

char* GetCurrentTime();

class CTime
{
protected:
    SYSTEMTIME m_stTime;

public:
    CTime()
    {
        GetLocalTime( &m_stTime );
    }

    int GetHourH(void)
    {
        return (m_stTime.wHour / 10);
    }
    int GetHourL(void)
    {
        return (m_stTime.wHour % 10);
    }

    int GetMinH(void)
    {
        return (m_stTime.wMinute / 10);
    }
    int GetMinL(void)
    {
        return (m_stTime.wMinute % 10);
    }

    int GetYearH(void)
    {
        return (m_stTime.wYear / 1000);
    }
    int GetYearMH(void)
    {
        return (m_stTime.wYear % 1000 / 100);
    }
    int GetYearML(void)
    {
        return (m_stTime.wYear % 1000 % 100 / 10);
    }
    int GetYearL(void)
    {
        return (m_stTime.wYear % 1000 % 100 % 10);
    }

    int GetMonthH(void)
    {
        return (m_stTime.wMonth / 10);
    }
    int GetMonthL(void)
    {
        return (m_stTime.wMonth % 10);
    }

    int GetDayH(void)
    {
        return (m_stTime.wDay / 10);
    }
    int GetDayL(void)
    {
        return (m_stTime.wDay % 10);
    }

    BOOL is_Am(void)
    {
        return (m_stTime.wHour < 12);
    }
};

class CTimeManager: public CTime
{
private:
    RECT	rtHome ;
    RECT	rtTime;
    RECT	rtData;
    RECT	rtActiveRegion;
public:
    CTimeManager() { }
    void	SetData( RECT rt );
    void	DrawTime(  HDC hMemoryDC, HDC hPublicMemoryDC );
    //void	DrawActiveBackGround(const HDC hdc, RECT rc);
    void	TimeDigitToChar( TCHAR* Buffer ,WORD wHour,WORD wMinute );

    ~CTimeManager() { }
};
